#include "tools.h"
#include <setjmp.h>
#include <cmocka.h>

void testGetTcpServerSocketDup(void **state){
    // test used port
    int sockfd = getTcpServerSocket(8888);
    int dup_sockfd = getTcpServerSocket(8888);
    assert_true(dup_sockfd < 0);
}

void testGetClientServerSocketWithInvalidServer(void **state){
    const char* invalidServer[] = {
        "what ever you call it",
        "time flys",
        "I am under heavy pressure"
    };

    for (int i = 0 ; i < 3 ; i++){
        assert_true(getTcpClientSocket(invalidServer[i], 8989) < 0);
    }
}

void testGetClientServerSocketWith(void **state){
}

int main(int argc, char** argv){
    const struct CMUnitTest tests[] = {
        cmocka_unit_test(testGetTcpServerSocketDup),
        cmocka_unit_test(testGetClientServerSocketWithInvalidServer),
    };

    return cmocka_run_group_tests(tests, NULL, NULL);
}
